import Vue from 'vue'
import VueRouter from 'vue-router'
// ---登录注册功能↓
import Reg from '@/views/Reg/Reg.vue'
import Login from '@/views/Login/Login.vue'

// 主页↓
import Home from '../views/Home/home.vue'

// 主页的儿子↓ 页面显示
import Welcome from '../views/Home/Welcome.vue'
// 用户信息
import Userinfo from '../views/UserInfo/UserInfo.vue'
// 用户头像
import Avatar from '../views/UserInfo/Useravatar.vue'
// 修改密码
import Pwd from '../views/UserInfo/UserPwd.vue'

// -------------------------
// 文章管理
import Artcate from '../views/Article/Artcate.vue'
// 文章列表
import ArtList from '../views/Article/ArtList.vue'
Vue.use(VueRouter)

const routes = [
  // {
  //   // 设置重定向 到登录页
  //   path: '/',
  //   redirect: '/reg'
  // },
  {
    // 注册页
    path: '/reg',
    component: Reg
  },
  {
    // 登录页
    path: '/login',
    component: Login
  },
  {
    path: '/',
    component: Home,
    redirect: '/home',
    children: [
      // {
      //   path: 'home',
      //   component: Home

      // },
      {
        // 设置为空的时候默认跳转到这个路由
        path: 'home',
        component: Welcome
      },
      {
        // 二级路由加/ 表示变成了一级路由 不太好
        path: 'user-info',
        component: Userinfo
      },
      {
        path: 'user-avatar',
        component: Avatar
      },
      {
        path: 'user-pwd',
        component: Pwd
      },
      {
        path: 'art-cate',
        component: Artcate
      }, {
        path: 'art-list',
        component: ArtList
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
